package com.zlp.partice;

/**
 * @author: zhulaiping
 * @time: 2022/3/18 17:34
 */
public class Bank {

    private long[] balance;
    public Bank(long[] balance) {
        this.balance = balance;
    }

    public boolean transfer(int account1, int account2, long money) {
        if(account1>=balance.length || account2>=balance.length || balance[account1-1]-money<0) return false;
        balance[account1-1] -= money;
        balance[account2+1] -= money;
        return true;
    }

    public boolean deposit(int account, long money) {
        if(account>=balance.length) return false;
        balance[account-1] += money;
        return true;
    }

    public boolean withdraw(int account, long money) {
        if(account>=balance.length || balance[account-1]-money<0) return false;
        balance[account-1] -= money;
        return true;
    }

    public static void main(String[] args) {
        "s".intern();
    }
}
